package com.bodu.depress.service.impl;

import com.bodu.core.entity.ParamReq;
import com.bodu.core.exception.custom.DeleteException;
import com.bodu.core.exception.custom.SaveException;
import com.bodu.core.exception.custom.SearchException;
import com.bodu.core.exception.custom.UpdateException;
import com.bodu.depress.entity.request.DepressCollectTypeRequest;
import com.bodu.depress.entity.vo.DepressCollectTypeVo;
import com.bodu.depress.service.DepressCollectTypeService;
import com.bodu.depress.mapper.DepressCollectTypeMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author Administrator
 */
@Service("depressCollectTypeService")
public class DepressCollectTypeServiceImpl implements DepressCollectTypeService {

    @Resource
    private DepressCollectTypeMapper depressCollectTypeMapper;

    @Override
    public DepressCollectTypeVo getModel(Long id) throws SearchException {
        return depressCollectTypeMapper.getModel(id);
    }

    @Override
    public Long save(DepressCollectTypeRequest request) throws SaveException {
        depressCollectTypeMapper.save(request);
        return request.getId();
    }

    @Override
    public Long update(DepressCollectTypeRequest request) throws UpdateException {
        depressCollectTypeMapper.update(request);
        return request.getId();
    }

    @Override
    public List<DepressCollectTypeVo> listPage(ParamReq<DepressCollectTypeRequest> t) throws SearchException {
        t.setStartIndex((t.getCurrent() - 1) * t.getSize());
        return depressCollectTypeMapper.listPage(t);
    }

    @Override
    public Integer countPage(ParamReq<DepressCollectTypeRequest> t) throws SearchException {
        return depressCollectTypeMapper.countPage(t);
    }

    @Override
    public Integer updateDelFlagById(Long id, Integer delFlag) throws DeleteException {
        return depressCollectTypeMapper.updateDelFlagById(id, delFlag);
    }
}
